package com.tanhua.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.api.mongo.UserLocationApi;
import com.tanhua.domain.vo.PageBeanVo;
import com.tanhua.mapper.UserInfoMapper;
import com.tanhua.service.UserInfoService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author user
 */
@Service
public class UserInfoServiceImpl implements UserInfoService {

    @Autowired
    public UserInfoMapper userInfoMapper;
    @Reference
    public UserLocationApi userLocationApi;


    @Override
    public PageBeanVo getUserInfoList(Integer page, Integer pageSize) {
        Page page1 = new Page<>(page, pageSize);
        IPage iPage = userInfoMapper.selectPage(page1, null);
        return new PageBeanVo(page, pageSize, iPage.getTotal(), iPage.getRecords());
    }


    /**
     * 获取用户坐标
     *
     * @param userid
     * @return
     */
    @Override
    public ResponseEntity getCoordinates(String userid) {
        Map<String, Double> map = userLocationApi.getCoordinates(userid);
        return ResponseEntity.ok(map);
    }

}
